package invoker {
	import command.CmdNo;
	import command.ICommand;
	import flash.utils.getQualifiedClassName;
	/**
	 * ...
	 * @author wibrst@qq.com
	 */
	public class RemoteCtrl {
		
		static public const ACT_TYPE_ON:String = "actTypeOn";
		static public const ACT_TYPE_OFF:String = "actTypeOff";
		
		public function RemoteCtrl() {
			this._cmdUndo = new CmdNo;
		}
		
		public function setCmd( cmdOn:ICommand, cmdOff:ICommand  ):void {
			this._cmdOff = cmdOff;
			this._cmdOn = cmdOn;
		}
		
		public function btnPressed( sType:String ):void {
			switch( sType ) {
			case ACT_TYPE_ON:
				this._cmdOn.execute();
				this._cmdUndo = this._cmdOff;
			break;
			case ACT_TYPE_OFF:
				this._cmdOff.execute();
				this._cmdUndo = this._cmdOn;
			break;
			}
		}
		
		public function undoPressed():void {
			this._cmdUndo.undo();
		}
		
		public function toString():String {
			var sBuff:String = 
				"------ ------ remote ctrl ------ ------"
				+ "\non:\t" + getQualifiedClassName( this._cmdOn )
				+ "\noff:\t" + getQualifiedClassName( this._cmdOff )
				+ "\nundo:\t" + getQualifiedClassName( this._cmdUndo );
			return sBuff;
		}

		private var _cmdOn:ICommand;
		private var _cmdOff:ICommand;
		
		private var _cmdUndo:ICommand;
		
	}

}